package org.come.Jpanel;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;

import org.come.Frame.MsgJframe;
import org.come.Frame.ZhuFrame;
import org.come.bean.AllHallucination;
import org.come.bean.Hallucination;
import org.come.bean.Skill;
import org.come.entity.Goodstable;
import org.come.entity.RoleSummoning;
import org.come.model.petExchange;
import org.come.mouslisten.HallucinationMouslisten;
import org.come.until.CutButtonImage;
import org.come.until.FormsManagement;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.ScrollUI;
import org.come.until.UserMessUntil;
import org.come.until.Util;
import org.come.until.ZipUtils;
import org.skill.panel.SkillSMSelectOptionJpanel;

import com.gl.util.Xy2Util;
import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.RefineOperBtn;
import com.tool.btn.experimentCompoundBtn;
import com.tool.image.ImageMixDeal;
import com.tool.tcp.NewPart;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

/**
 * 召唤兽幻化
 */
public class HallucinationJpanel extends JPanel {

	/**
	 * 物品消耗
	 */
	private static JLabel labgoods,labskill,labskill1,labskill2,labskill3;
	/**
	 * 新旧初值变化
	 */
	private static JLabel[] newlab = new JLabel[5];
	/**
	 * 方案选择
	 */
	public static JLabel[] labColorS = new JLabel[8];
	/**
	 * 召唤兽名称
	 */
	public static JLabel laboldname,labnewname,labskillName,labColor,labSelectColor,labtit,labtitle;



	private static BigDecimal money;
	private List<Goodstable> goodsList;
	private String valuest;
	private experimentCompoundBtn btnCompound;

	public static boolean ishh = false;
	// 召唤兽列表
	private static JList<String> listpet;
	// 列表中的对象
	private static DefaultListModel<String> listModel;// 放置召唤兽的对象

	// 列表中对象的名字颜色
	private Color fontcolor;
	// 滚动条
	private JScrollPane jScrollPane;

	public static Map<String, Hallucination> dbHallucination;

	public static Map<String, RoleSummoning> dbTujian;

	private static int warNum = -1;

	private static String goodnumber = "0";

	public static String selectColor = "";

	public static NewPart oldpart;

	public static NewPart newpart;

	public static List<RoleSummoning> selectPetList = new ArrayList<RoleSummoning>();//所有可幻化的

	public static String selectPet;//选中的待幻化的

	public static String selectHHPet;//选中的幻化数据

	public static List<String> selectPetName;//待选集合

	private static SkillSMSelectOptionJpanel optionJpanel;// 下拉框

	private static JLabel labName;

	private static RefineOperBtn btnDown;// 下拉框

	public static String[] rowData = {};

	public static Hallucination selecthallucination;


	public HallucinationJpanel() {
		if (MyIsif.getStyle().equals("水墨UI")) {
			setPreferredSize(new Dimension(616, 442));
			setOpaque(false);
			setLayout(null);

			FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/button/64.png", 1, 3019);
			offBtn.setBounds(616 - 25, 0, 25, 25);
			this.add(offBtn);
			initpets();

			labtitle = new JLabel();
			labtitle.setForeground(UIUtils.COLOR_FightingRound_Black);
			labtitle.setHorizontalAlignment(SwingConstants.CENTER);
			labtitle.setFont(UIUtils.TEXT_HY19);
			labtitle.setText("大话幻化");
			labtitle.setBounds(285 , -5, 150, 50);
			this.add(labtitle);
			laboldname = new JLabel();
			laboldname.setForeground(UIUtils.COLOR_CHENS);
			laboldname.setHorizontalAlignment(SwingConstants.CENTER);
			laboldname.setFont(UIUtils.TEXT_HY17);
			laboldname.setBounds(180 , 20, 150, 50);
			this.add(laboldname);

			labnewname = new JLabel();
			labnewname.setForeground(UIUtils.COLOR_CHENS);
			labnewname.setHorizontalAlignment(SwingConstants.CENTER);
			labnewname.setFont(UIUtils.TEXT_HY17);
			labnewname.setBounds(455, 20, 150, 50);
			this.add(labnewname);

			labskillName = new JLabel();
			labskillName.setForeground(UIUtils.COLOR_CHENS);
			labskillName.setFont(UIUtils.TEXT_HY16);
			labskillName.setText("幻化技能");
			labskillName.setBounds(355 , 265, 250, 50);
			this.add(labskillName);

			labColor = new JLabel();
			labColor.setForeground(UIUtils.COLOR_FightingRound_Black);
			labnewname.setHorizontalAlignment(SwingConstants.CENTER);
			labColor.setFont(UIUtils.TEXT_HY17);
			labColor.setText("配色方案");
			labColor.setBounds(500 , 265, 250, 50);
			this.add(labColor);

			labtit = new JLabel();
			labtit.setForeground(UIUtils.COLOR_FightingRound_Black);
			labnewname.setHorizontalAlignment(SwingConstants.CENTER);
			labtit.setFont(UIUtils.TEXT_HY17);
			labtit.setText("初值变化");
			labtit.setBounds(225 , 265, 250, 50);
			this.add(labtit);

			labSelectColor = new JLabel();
			this.add(labSelectColor);

			for(int i=0;i<5;i++) {
				newlab[i] = new JLabel();
				newlab[i].setForeground(UIUtils.COLOR_FightingRound_Black);
				newlab[i].setFont(UIUtils.TEXT_FONT61);
				newlab[i].setBounds(200 , 290+ 22*i, 200, 50);
				this.add(newlab[i]);
			}

			for(int i=0;i<8;i++) {
				labColorS[i] = new JLabel();
				labColorS[i].setForeground(UIUtils.COLOR_FightingRound_Black);
				labColorS[i].setFont(UIUtils.TEXT_FONT61);
				int x = 0;
				int y = i;
				if(i>3) {
					y = i-4;
					x = 80;
				}
				HallucinationJpanel.labColorS[i].setBounds(460 +x, 295 + 25*y, 65, 25);
				labColorS[i].addMouseListener(new HallucinationMouslisten(i,null, this));
				this.add(labColorS[i]);
			}
		}else{
			setPreferredSize(new Dimension(616, 442));
			setOpaque(false);
			setLayout(null);

			FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/hongmu/s74.png", 1, 3019);//红木
			offBtn.setBounds(616 - 25, 0, 25, 25);
			this.add(offBtn);
			initpets();

			labtitle = new JLabel();
			labtitle.setForeground(UIUtils.COLOR_TEXT1);
			labtitle.setHorizontalAlignment(SwingConstants.CENTER);
			labtitle.setFont(UIUtils.TEXT_HY19);
			labtitle.setText("大话幻化");
			labtitle.setBounds(250 , -10, 150, 50);
			this.add(labtitle);
			laboldname = new JLabel();
			laboldname.setForeground(UIUtils.COLOR_TEXT1);
			laboldname.setHorizontalAlignment(SwingConstants.CENTER);
			laboldname.setFont(UIUtils.TEXT_HY17);
			laboldname.setBounds(180 , 35, 150, 50);
			this.add(laboldname);

			labnewname = new JLabel();
			labnewname.setForeground(UIUtils.COLOR_TEXT1);
			labnewname.setHorizontalAlignment(SwingConstants.CENTER);
			labnewname.setFont(UIUtils.TEXT_HY17);
			labnewname.setBounds(455, 35, 150, 50);
			this.add(labnewname);

			labskillName = new JLabel();
			labskillName.setForeground(UIUtils.COLOR_CHENS);
			labskillName.setFont(UIUtils.TEXT_HY16);
			labskillName.setText("幻化技能");
			labskillName.setBounds(355 , 265, 250, 50);
			this.add(labskillName);

			labColor = new JLabel();
			labColor.setForeground(UIUtils.COLOR_TEXT1);
			labnewname.setHorizontalAlignment(SwingConstants.CENTER);
			labColor.setFont(UIUtils.TEXT_HY17);
			labColor.setText("配色方案");
			labColor.setBounds(500 , 265, 250, 50);
			this.add(labColor);

			labtit = new JLabel();
			labtit.setForeground(UIUtils.COLOR_TEXT1);
			labnewname.setHorizontalAlignment(SwingConstants.CENTER);
			labtit.setFont(UIUtils.TEXT_HY17);
			labtit.setText("初值变化");
			labtit.setBounds(225 , 265, 250, 50);
			this.add(labtit);

			labSelectColor = new JLabel();
			this.add(labSelectColor);

			for(int i=0;i<5;i++) {
				newlab[i] = new JLabel();
				newlab[i].setForeground(UIUtils.COLOR_TEXT1);
				newlab[i].setFont(UIUtils.TEXT_FONT61);
				newlab[i].setBounds(200 , 290+ 22*i, 200, 50);
				this.add(newlab[i]);
			}

			for(int i=0;i<8;i++) {
				labColorS[i] = new JLabel();
				labColorS[i].setForeground(UIUtils.COLOR_TEXT1);
				labColorS[i].setFont(UIUtils.TEXT_FONT61);
				int x = 0;
				int y = i;
				if(i>3) {
					y = i-4;
					x = 80;
				}
				HallucinationJpanel.labColorS[i].setBounds(460 +x, 295 + 25*y, 65, 25);
				labColorS[i].addMouseListener(new HallucinationMouslisten(i,null, this));
				this.add(labColorS[i]);
			}
		}
		// 召唤兽列表
		listpet = new JList<String>() {
			{
				setOpaque(false);
			} // instance initializer
		};
		listpet.setSelectionBackground(new Color(33, 42, 52));
		fontcolor = Color.white;// 203,181,91
		listpet.setSelectionForeground(fontcolor);//鼠标点击后的颜色显示
		listpet.setForeground(new Color(205,205,108));
		listpet.setFont(UIUtils.TEXT_MSGX);
		listpet.setBackground(UIUtils.Color_BACK); // 设置列表框为透明背景
		listpet.setModel(listModel);
		listpet.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		listpet.setCellRenderer(new CustomRenderer()); // 设置自定义渲染器
//		listpet.setCellRenderer(new MyRenderer());
		listpet.addMouseListener(new HallucinationMouslisten(999,listpet, this));
		listpet.addMouseMotionListener(new HallucinationMouslisten(999,listpet, this));

		// 召唤兽列表滚动条
		jScrollPane = new JScrollPane(listpet);
		jScrollPane.setVerticalScrollBarPolicy(22);
		jScrollPane.getVerticalScrollBar().setUI(new ScrollUI());
		jScrollPane.getViewport().setOpaque(false);
		jScrollPane.setOpaque(false);
		jScrollPane.setBounds(25, 41, 154, 368);
		jScrollPane.setBorder(BorderFactory.createLineBorder(new Color(31, 7, 8)));
		jScrollPane.setHorizontalScrollBarPolicy(31);
		this.add(this.jScrollPane);

		//幻化技能展示
		labskill = new JLabel();
		labskill.setForeground(UIUtils.COLOR_TEXT1);
		labskill.setFont(UIUtils.TEXT_HY17);
		labskill.setBounds(344 , 310, 50, 50);
		labskill.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent e) {
				if (labskill.isVisible()) {
					Skill skill = UserMessUntil.getskill1(labskill.getText());
					if (skill == null) {
						return;
					}
					MsgJframe
							.getJframe()
							.getJapnel()
							.skillmsg(skill);
				}
			}
			@Override
			public void mouseExited(MouseEvent e) {
				FormsManagement.HideForm(46);
			}
		});
		this.add(labskill);
		labskill1 = new JLabel();
		labskill1.setForeground(UIUtils.COLOR_TEXT1);
		labskill1.setFont(UIUtils.TEXT_HY17);
		labskill1.setBounds(396 , 310, 50, 50);
		labskill1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent e) {
				if (labskill1.isVisible()) {
					Skill skill = UserMessUntil.getskill1(labskill1.getText());
					if (skill == null) {
						return;
					}
					MsgJframe
							.getJframe()
							.getJapnel()
							.skillmsg(skill);
				}
			}
			@Override
			public void mouseExited(MouseEvent e) {
				FormsManagement.HideForm(46);
			}
		});
		this.add(labskill1);
		labskill2 = new JLabel();
		labskill2.setForeground(UIUtils.COLOR_TEXT1);
		labskill2.setFont(UIUtils.TEXT_HY17);
		labskill2.setBounds(344 , 361, 50, 50);
		labskill2.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent e) {
				if (labskill2.isVisible()) {
					Skill skill = UserMessUntil.getskill1(labskill2.getText());
					if (skill == null) {
						return;
					}
					MsgJframe
							.getJframe()
							.getJapnel()
							.skillmsg(skill);
				}
			}
			@Override
			public void mouseExited(MouseEvent e) {
				FormsManagement.HideForm(46);
			}
		});
		this.add(labskill2);
		labskill3 = new JLabel();
		labskill3.setForeground(UIUtils.COLOR_TEXT1);
		labskill3.setFont(UIUtils.TEXT_HY17);
		labskill3.setBounds(396 , 361, 50, 50);
		labskill3.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent e) {
				if (labskill3.isVisible()) {
					Skill skill = UserMessUntil.getskill1(labskill3.getText());
					if (skill == null) {
						return;
					}
					MsgJframe
							.getJframe()
							.getJapnel()
							.skillmsg(skill);
				}
			}
			@Override
			public void mouseExited(MouseEvent e) {
				FormsManagement.HideForm(46);
			}
		});
		this.add(labskill3);
		labgoods = new JLabel();
		labgoods.setForeground(UIUtils.COLOR_TEXT1);
		labgoods.setFont(UIUtils.TEXT_HY17);
		labgoods.setBounds(360 , 77, 70, 70);
		labgoods.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseEntered(MouseEvent e) {
				if (labgoods.isVisible()) {
					Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(labgoods.getText()));
					ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
				}
			}
			@Override
			public void mouseExited(MouseEvent e) {
				ZhuFrame.getZhuJpanel().cleargoodtext();
			}
		});
		this.add(labgoods);




		labName = new JLabel();
		labName.setBounds(212-6, 250, 106, 16);
		labName.setForeground(Color.white);
		labName.setFont(UIUtils.TEXT_HY16);
		this.add(labName);
		btnDown = new RefineOperBtn("img/xy2uiimg/47_png.button.combobox.png", 1, this, 10101);
		btnDown.setBounds(210-8, 249, 175, 22);
		this.add(btnDown);
		optionJpanel = new SkillSMSelectOptionJpanel(110, 55, "img/xy2uiimg/tishikuang.png", rowData);
		optionJpanel.setBounds(210-8, 270, 175, 55);
		optionJpanel.setVisible(false);
		this.add(optionJpanel);
		optionJpanel.getJlist().addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				String value = getValue(true);
				if(value!=null){
					optionJpanel.setVisible(false);
				}
			}
		});
		getBtnCompound();
	}

	public void initpets() {
		dbHallucination = new HashMap<String, Hallucination>();
		dbTujian = new HashMap<String, RoleSummoning>();
		listModel = new DefaultListModel<String>();
		if(listModel!=null) {
			listModel.clear();
		}
		AllHallucination lists = UserMessUntil.getAllHallucination();
		Map<BigDecimal, Hallucination> item = lists.getHallucinationConcurrentHashMap();
		for (Entry<BigDecimal, Hallucination> entry : item.entrySet()) {
			listModel.addElement(entry.getValue().getOldname());
			dbHallucination.put(entry.getValue().getOldname(), entry.getValue());
		}
		List<RoleSummoning> list = new ArrayList<>();

		if(UserMessUntil.getAllPetExchange()!=null){
			for(Entry<Integer, petExchange> entry : UserMessUntil.getAllPetExchange().getAllPetExchange().entrySet()){
				RoleSummoning pet = new RoleSummoning();
				pet.setSummoningid(entry.getValue().getPid().toString());
				pet.setSummoningname(entry.getValue().getName());
				pet.setSummoningskin(entry.getValue().getSkin());
				pet.setGrowlevel(entry.getValue().getGrow()+"");
				pet.setAp(entry.getValue().getAp());
				pet.setHp(entry.getValue().getHp());
				pet.setMp(entry.getValue().getMp());
				pet.setSp(entry.getValue().getSp());
				list.add(pet);
			}
		}
		if(list!=null) {
			for(int cs=0;cs<list.size();cs++) {
				dbTujian.put(list.get(cs).getSummoningid(), list.get(cs));
			}
		}
	}

	//界面展示
	public static void showAll(Hallucination hallucination) {
//		if(optionJpanel.isVisible()){
//			showArenaDownLab();
//		}
		selecthallucination = hallucination;
		selectHHPet = hallucination.getId();
		selectPetList = new ArrayList<>();
		selectPetName = new ArrayList<>();
		List<RoleSummoning> petList = UserMessUntil.getPetListTable();
		if(petList!=null) {
			Collections.sort(petList, (o1, o2) -> Integer.compare(Integer.parseInt(o1.getSid().toString()), Integer.parseInt(o2.getSid().toString())));
			for(RoleSummoning summoning:petList) {
				if(hallucination.getOldpet().equals(summoning.getSummoningid()) && (summoning.getHhschedule() == null ||summoning.getHhschedule().equals("") )) {
					selectPetList.add(summoning);
					selectPetName.add(summoning.getSummoningname());
				}
			}
		}
		rowData = new String[selectPetName.size()];
		if(selectPetName!=null && rowData.length>0) {
			for(int i=0;i<selectPetName.size();i++){
				rowData[i] = selectPetName.get(i);
			}
			labName.setText(rowData[0]);
		}else{
			labName.setText("");
		}

		if(labName.getText()!=null){
			optionJpanel.setVisible(false);
			labName.setVisible(false);
			btnDown.setVisible(false);
		}else{
			optionJpanel.setVisible(false);
			labName.setVisible(true);
			btnDown.setVisible(true);
		}

		optionJpanel.clearModelContent(rowData);
		if(selectPetList!=null&& selectPetList.size()>0) {
			selectPet = selectPetList.get(0).getSid().toString();
		}else{
			selectPet = "";
		}
		//消耗
		int goodNum = GoodsListFromServerUntil.getGoodNum(new BigDecimal(hallucination.getGoods()));
		if(goodNum>=hallucination.getNumber()) {
			ishh = true;
		}else {
			ishh = false;
		}
		goodnumber = goodNum+"/"+hallucination.getNumber();

		money = new BigDecimal(hallucination.getMoney());

		labnewname.setText(hallucination.getNewname());

		laboldname.setText(hallucination.getOldname());

		RoleSummoning summoning = dbTujian.get(hallucination.getOldpet());
		String[] up = hallucination.getIncrease().split("\\|");

//    	oldlab[0].setText("成长："+summoning.getGrowlevel());
//    	oldlab[1].setText("HP："+summoning.getHp()+"");
//    	oldlab[2].setText("MP："+summoning.getMp()+"");
//    	oldlab[3].setText("AP："+summoning.getAp()+"");
//    	oldlab[4].setText("SP："+summoning.getSp()+"");
		if (MyIsif.getStyle().equals("水墨UI")) {
			Double grow = Double.parseDouble(hallucination.getGrow());
			int hp = Integer.parseInt(up[0]);
			int mp = Integer.parseInt(up[1]);
			int ap = Integer.parseInt(up[2]);
			int sp = Integer.parseInt(up[3]);
			if(grow>=0) {
				newlab[0].setText("<html><body><font color='#302e27'>" + summoning.getGrowlevel() + "</font><font color='#00EE00'>" + hallucination.getGrow() + "</body></html>");
			}else {
				newlab[0].setText("<html><body><font color='#302e27'>" + summoning.getGrowlevel() + "</font><font color='#FF3030'>" + hallucination.getGrow() + "</body></html>");
			}
			if(hp>=0) {
				newlab[1].setText("<html><body><font color='#302e27'>HP：" + summoning.getHp() + "</font><font color='#00EE00'> + " + up[0] + "</body></html>");
			}else {
				newlab[1].setText("<html><body><font color='#302e27'>HP：" + summoning.getHp() + "</font><font color='#FF3030'> - " + up[0] + "</body></html>");
			}
			if(mp>=0) {
				newlab[2].setText("<html><body><font color='#302e27'>MP：" + summoning.getMp() + "</font><font color='#00EE00'> + " + up[1] + "</body></html>");
			}else {
				newlab[2].setText("<html><body><font color='#302e27'>MP：" + summoning.getMp() + "</font><font color='#FF3030'> - " + up[1] + "</body></html>");
			}
			if(ap>=0) {
				newlab[3].setText("<html><body><font color='#302e27'>AP：" + summoning.getAp() + "</font><font color='#00EE00'> + " + up[2] + "</body></html>");
			}else {
				newlab[3].setText("<html><body><font color='#302e27'>AP：" + summoning.getAp() + "</font><font color='#FF3030'> - " + up[2] + "</body></html>");
			}
			if(sp>=0) {
				newlab[4].setText("<html><body><font color='#302e27'>SP：" + summoning.getSp() + "</font><font color='#00EE00'> + " + up[3] + "</body></html>");
			}else {
				newlab[4].setText("<html><body><font color='#302e27'>SP：" + summoning.getSp() + "</font><font color='#FF3030'> - " + up[3] + "</body></html>");
			}
		}else{
			Double grow = Double.parseDouble(hallucination.getGrow());
			int hp = Integer.parseInt(up[0]);
			int mp = Integer.parseInt(up[1]);
			int ap = Integer.parseInt(up[2]);
			int sp = Integer.parseInt(up[3]);
			if(grow>=0) {
				newlab[0].setText("<html><body><font color='#BBA54B'>" + summoning.getGrowlevel() + "</font><font color='#00EE00'>" + hallucination.getGrow() + "</body></html>");
			}else {
				newlab[0].setText("<html><body><font color='#BBA54B'>" + summoning.getGrowlevel() + "</font><font color='#FF3030'>" + hallucination.getGrow() + "</body></html>");
			}
			if(hp>=0) {
				newlab[1].setText("<html><body><font color='#BBA54B'>HP：" + summoning.getHp() + "</font><font color='#00EE00'> + " + up[0] + "</body></html>");
			}else {
				newlab[1].setText("<html><body><font color='#BBA54B'>HP：" + summoning.getHp() + "</font><font color='#FF3030'> - " + up[0] + "</body></html>");
			}
			if(mp>=0) {
				newlab[2].setText("<html><body><font color='#BBA54B'>MP：" + summoning.getMp() + "</font><font color='#00EE00'> + " + up[1] + "</body></html>");
			}else {
				newlab[2].setText("<html><body><font color='#BBA54B'>MP：" + summoning.getMp() + "</font><font color='#FF3030'> - " + up[1] + "</body></html>");
			}
			if(ap>=0) {
				newlab[3].setText("<html><body><font color='#BBA54B'>AP：" + summoning.getAp() + "</font><font color='#00EE00'> + " + up[2] + "</body></html>");
			}else {
				newlab[3].setText("<html><body><font color='#BBA54B'>AP：" + summoning.getAp() + "</font><font color='#FF3030'> - " + up[2] + "</body></html>");
			}
			if(sp>=0) {
				newlab[4].setText("<html><body><font color='#BBA54B'>SP：" + summoning.getSp() + "</font><font color='#00EE00'> + " + up[3] + "</body></html>");
			}else {
				newlab[4].setText("<html><body><font color='#BBA54B'>SP：" + summoning.getSp() + "</font><font color='#FF3030'> - " + up[3] + "</body></html>");
			}
		}
		//技能
		if(hallucination.getAddskill()!=null) {
			String[] skills = hallucination.getAddskill().split("\\|");
			Skill skill = UserMessUntil.getSkillId(skills[0]);
			labskill.setVisible(true);
			ImageIcon imgSkill = CutButtonImage.getImage("inkImg/old/skill/wxs_" + skills[0] + ".png", 48, 48);
			labskill.setIcon(imgSkill);
			labskill.setText(skill.getSkillname());
			if(skills.length>1){
				skill = UserMessUntil.getSkillId(skills[1]);
				labskill1.setVisible(true);
				imgSkill = CutButtonImage.getImage("inkImg/old/skill/wxs_" + skills[1] + ".png", 48, 48);
				labskill1.setIcon(imgSkill);
				labskill1.setText(skill.getSkillname());
			}else{
				labskill1.setIcon(null);
				labskill1.setVisible(false);
			}
			if(skills.length>2){
				skill = UserMessUntil.getSkillId(skills[2]);
				labskill2.setVisible(true);
				imgSkill = CutButtonImage.getImage("inkImg/old/skill/wxs_" + skills[2] + ".png", 48, 48);
				labskill2.setIcon(imgSkill);
				labskill2.setText(skill.getSkillname());
			}else{
				labskill2.setIcon(null);
				labskill2.setVisible(false);
			}
			if(skills.length>3){
				skill = UserMessUntil.getSkillId(skills[3]);
				labskill3.setVisible(true);
				imgSkill = CutButtonImage.getImage("inkImg/old/skill/wxs_" + skills[3] + ".png", 48, 48);
				labskill3.setIcon(imgSkill);
				labskill3.setText(skill.getSkillname());
			}else{
				labskill3.setIcon(null);
				labskill3.setVisible(false);
			}
		}else {
			labskill.setIcon(null);
			labskill.setVisible(false);
			labskill1.setIcon(null);
			labskill1.setVisible(false);
			labskill2.setIcon(null);
			labskill2.setVisible(false);
			labskill3.setIcon(null);
			labskill3.setVisible(false);
		}

		//
		labgoods.setText(hallucination.getGoods());
		Goodstable goodstable = UserMessUntil.getgoodstable(new BigDecimal(hallucination.getGoods()));
		ImageIcon imggod = CutButtonImage.getImage("img/item/" + goodstable.getSkin() + ".png", 70, 70);
		labgoods.setIcon(imggod);
	}


	private ImageIcon icon = new ImageIcon("img/xy2uiimg/召唤兽幻化.png");
	private ImageIcon icon1 = new ImageIcon("img/xy2uiimg/召唤兽幻化1.png");
	@Override
	protected void paintComponent(Graphics g) {
		if("水墨UI".equals(MyIsif.getStyle())) {
			// TODO Auto-generated method stub
			super.paintComponent(g);
			g.drawImage(icon1.getImage(), 0, 0, 616, 442, null);
			Util.drawMoney(g, 350, 210);
			if (money != null) {
				Util.drawPrice(g, money, 350, 180);
			}
			if(oldpart!=null) {
				oldpart.draw(g, 280, 240, 0, ImageMixDeal.userimg.getTime());
				newpart.draw(g, 525, 240, 0, ImageMixDeal.userimg.getTime());
			}
			if(ishh) {
				g.setColor(Color.green);
			}else {
				g.setColor(Color.white);
			}
			g.drawString(goodnumber+"", 365, 92);
		} else {
			// TODO Auto-generated method stub
			super.paintComponent(g);
			g.drawImage(icon.getImage(), 0, 0, 616, 442, null);
			Util.drawMoney(g, 350, 210);
			if (money != null) {
				Util.drawPrice(g, money, 350, 180);
			}
			if(oldpart!=null) {
				oldpart.draw(g, 280, 240, 0, ImageMixDeal.userimg.getTime());
				newpart.draw(g, 525, 240, 0, ImageMixDeal.userimg.getTime());
			}
			if(ishh) {
				g.setColor(Color.green);
			}else {
				g.setColor(Color.white);
			}
			g.drawString(goodnumber+"", 365, 92);
		}

	}

	public static BigDecimal getMoney() {
		return money;
	}

	public static void setMoney(BigDecimal money) {
		HallucinationJpanel.money = money;
	}

	public List<Goodstable> getGoodsList() {
		return goodsList;
	}

	public void setGoodsList(List<Goodstable> goodsList) {
		this.goodsList = goodsList;
	}

	public experimentCompoundBtn getBtnCompound() {
		if("水墨UI".equals(MyIsif.getStyle())) {
			if (btnCompound == null) {
				btnCompound = new experimentCompoundBtn("inkImg/button/32.png", 1, UIUtils.COLOR_BLACK, "幻化",
						UIUtils.TEXT_HY16, 2, this);
				btnCompound.setBounds(365, 220, 60, 26);
				this.add(btnCompound);
			}
		}else {
			if (btnCompound == null) {
				btnCompound = new experimentCompoundBtn("inkImg/hongmu/6026.png", 1, UIUtils.COLOR_BTNPUTONG, "幻化",
						UIUtils.TEXT_HY16, 2, this);
				btnCompound.setBounds(365, 230, 60, 26);
				this.add(btnCompound);
			}
		}
		return btnCompound;
	}

	public void setBtnCompound(experimentCompoundBtn btnCompound) {
		this.btnCompound = btnCompound;
	}

	public static DefaultListModel<String> getListModel() {
		return listModel;
	}

	public static void setListModel(DefaultListModel<String> listModel) {
		HallucinationJpanel.listModel = listModel;
	}
	public static ImageIcon img = CutButtonImage.getImage("img/xy2uiimg/幻.png", 20, 20);
	private static class CustomRenderer extends DefaultListCellRenderer {
		@Override
		public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
													  boolean cellHasFocus) {
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
			List<RoleSummoning> petList = UserMessUntil.getPetListTable();
			Hallucination hallucination = dbHallucination.get(value.toString());
			this.setForeground(new Color(105, 105, 105));
			if(petList!=null) {
				for(RoleSummoning pet : petList) {
					if (pet.getSummoningid().equals(hallucination.getOldpet()) && pet.getHhschedule()==null) {
						this.setForeground(new Color(238, 220, 130));
						this.setIcon(img);
					}
				}
			}
			return this;
		}
	}



	/** 展示与隐藏下拉框 */
	public static void showArenaDownLab() {
		optionJpanel.setVisible(!optionJpanel.isVisible());
	}

	/**选择召唤兽*/
	public String getValue(boolean type) {
		JList<String> jlist = optionJpanel.getJlist();
		String selectedValue = jlist.getSelectedValue();
		labName.setText(selectedValue);
		Hallucination hallucination = dbHallucination.get(selectedValue);
		RoleSummoning summoning = selectPetList.get(jlist.getSelectedIndex());
		if(summoning!=null) {
			selectPet = summoning.getSid().toString();
			String[] up = hallucination.getIncrease().split("\\|");
			Double grow = Double.parseDouble(hallucination.getGrow());
			int hp = Integer.parseInt(up[0]);
			int mp = Integer.parseInt(up[1]);
			int ap = Integer.parseInt(up[2]);
			int sp = Integer.parseInt(up[3]);
			if(grow>=0) {
				newlab[0].setText("<html><body><font color='#BBA54B'>" + summoning.getGrowlevel() + "</font><font color='#00EE00'>" + hallucination.getGrow() + "</body></html>");
			}else {
				newlab[0].setText("<html><body><font color='#BBA54B'>" + summoning.getGrowlevel() + "</font><font color='#FF3030'>" + hallucination.getGrow() + "</body></html>");
			}
			if(hp>=0) {
				newlab[1].setText("<html><body><font color='#BBA54B'>HP：" + summoning.getHp() + "</font><font color='#00EE00'> + " + up[0] + "</body></html>");
			}else {
				newlab[1].setText("<html><body><font color='#BBA54B'>HP：" + summoning.getHp() + "</font><font color='#FF3030'> - " + up[0] + "</body></html>");
			}
			if(mp>=0) {
				newlab[2].setText("<html><body><font color='#BBA54B'>MP：" + summoning.getMp() + "</font><font color='#00EE00'> + " + up[1] + "</body></html>");
			}else {
				newlab[2].setText("<html><body><font color='#BBA54B'>MP：" + summoning.getMp() + "</font><font color='#FF3030'> - " + up[1] + "</body></html>");
			}
			if(ap>=0) {
				newlab[3].setText("<html><body><font color='#BBA54B'>AP：" + summoning.getAp() + "</font><font color='#00EE00'> + " + up[2] + "</body></html>");
			}else {
				newlab[3].setText("<html><body><font color='#BBA54B'>AP：" + summoning.getAp() + "</font><font color='#FF3030'> - " + up[2] + "</body></html>");
			}
			if(sp>=0) {
				newlab[4].setText("<html><body><font color='#BBA54B'>SP：" + summoning.getSp() + "</font><font color='#00EE00'> + " + up[3] + "</body></html>");
			}else {
				newlab[4].setText("<html><body><font color='#BBA54B'>SP：" + summoning.getSp() + "</font><font color='#FF3030'> - " + up[3] + "</body></html>");
			}
		}
		return selectedValue;
	}

	/** 隐藏或展示 选择召唤兽*/
	public String concealArena(boolean type) {
		optionJpanel.setVisible(false);
		btnDown.setVisible(type);
		labName.setVisible(type);
		if(type){
			return getValue(false);
		}
		return null;
	}
}
